//package com.plian.system.service.transfer.impl;
//
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.plian.Tools.CollectionUtil;
//import com.plian.system.entity.lg.LawDispute;
//import com.plian.system.entity.lg.LawDisputeCaseTracing;
//import com.plian.system.entity.lg.LawDisputeSummary;
//import com.plian.system.entity.lg.MlegalProceedingsArbitration;
//import com.plian.system.service.lg.ILawDisputeCaseTracingService;
//import com.plian.system.service.lg.ILawDisputeService;
//import com.plian.system.service.lg.ILawDisputeSummaryService;
//import com.plian.system.service.lg.IMlegalProceedingsArbitrationService;
//import com.plian.system.service.sys.orgzation.IOrgService;
//import com.plian.system.service.transfer.ILawDisputeTransferService;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//
//import java.util.List;
//import java.util.Map;
//import java.util.stream.Collectors;
//
//@Slf4j
//@Service
//@AllArgsConstructor
//public class LawDisputeTransferServiceImpl implements ILawDisputeTransferService {
//
//    private IOrgService orgService;
//
//    private ILawDisputeSummaryService lawDisputeSummaryService;
//
//    private IMlegalProceedingsArbitrationService mlegalProceedingsArbitrationService;
//
//    private ILawDisputeService lawDisputeService;
//
//    private ILawDisputeCaseTracingService lawDisputeCaseTracingService;
//
//    private final static String FULL_YEAR_CODE = "115002";
//
//    @Override
//    public List<LawDisputeSummary> oldSummaryList(String orgId) {
//        List<String> allChildIds = orgService.getAllChildIds(orgId);
//        return lawDisputeSummaryService.list(Wrappers.<LawDisputeSummary>lambdaQuery()
//                .in(LawDisputeSummary::getFillingUnitId, allChildIds)
////                .eq(LawDisputeSummary::getStatus, FormStatusConstant.FINISH)
//                .eq(LawDisputeSummary::getTimeSpanId, FULL_YEAR_CODE));
//    }
//
//    @Override
//    public List<MlegalProceedingsArbitration> oldArbitrationList(String orgId) {
//        List<String> allChildIds = orgService.getAllChildIds(orgId);
//        return mlegalProceedingsArbitrationService.list(Wrappers.<MlegalProceedingsArbitration>lambdaQuery()
////                .eq(MlegalProceedingsArbitration::getStatus, FormStatusConstant.FINISH)
//                .in(MlegalProceedingsArbitration::getFillingUnitId, allChildIds));
//    }
//
//    @Override
//    public List<LawDispute> lawDisputeList(String orgId) {
//        List<String> allChildIds = orgService.getAllChildIds(orgId);
//        List<LawDispute> lawDisputeList = lawDisputeService.list(Wrappers.<LawDispute>lambdaQuery()
////                .eq(LawDispute::getStatus, FormStatusConstant.FINISH)
//                .in(LawDispute::getFillingUnitId, allChildIds));
//        if (CollectionUtil.isEmpty(lawDisputeList)) {
//            return lawDisputeList;
//        }
//        List<LawDisputeCaseTracing> lawDisputeCaseTracingList = lawDisputeCaseTracingService.list(Wrappers.<LawDisputeCaseTracing>lambdaQuery()
//                .in(LawDisputeCaseTracing::getLawDisputeId, lawDisputeList.stream().map(LawDispute::getId).toArray()));
//        if (CollectionUtil.isNotEmpty(lawDisputeCaseTracingList)){
//            Map<Long, List<LawDisputeCaseTracing>> tracingMap = lawDisputeCaseTracingList.stream().collect(Collectors.groupingBy(LawDisputeCaseTracing::getLawDisputeId));
//            for (LawDispute lawDispute : lawDisputeList) {
//                if (tracingMap.containsKey(lawDispute.getId())){
//                    lawDispute.setLawDisputeCaseTracings(tracingMap.get(lawDispute.getId()).stream()
//                            .sorted((o2, o1) -> o1.getCreateTime().compareTo(o2.getCreateTime())).collect(Collectors.toList()));
//                }
//            }
//        }
//        return lawDisputeList;
//    }
//}
